<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
    <link type="text/css" rel="stylesheet" href="css/style.css"/>
    <script src="js/axios.min.js"></script>
    <script src="js/vue.min.js"></script>
</head>
<body>
<div id="app">

	<div id="header" class="wrap">
		<img src="images/logo.gif"/>
	</div>
	<div id="login" class="wrap">
		<div class="main">
			<div class="corner"></div>
			<div class="introduce">
				<h2>源辰信息</h2>
				<p>网上调查系统...</p>
			</div>
			<div class="login">
				<h2>用户登录</h2>
				<form method="post" action="manage.html">
					<dl id="loginBox">
						<dt>用户名：</dt>
						<dd><input type="text" class="input-text" v-model="user.name" value=""/></dd>
						<dt>密　码：</dt>
						<dd><input type="password" class="input-text" v-model="user.pwd" value=""/></dd>
						<dt></dt>
						<dd><input type="submit" @click.prevent="login" class="input-button" name="submit" value="登录"/>
							<a href="register.html">新用户注册</a>
						</dd>
					</dl>
				</form>
				<div class="error"></div>
			</div>
		</div>
	</div>
	<div class="wrap">
	</div>
	<div id="footer" class="wrap">
		源辰信息 &copy; 版权所有
	</div>
</div>
<script>
	var v = new Vue({
		el: '#app',
		data:{
			user:{name:"",pwd:""}
		},
		methods:{
			login(){
				let p = new URLSearchParams();
				p.append("name",this.user.name);
				p.append("pwd",this.user.pwd);
				axios.post("LoginServlet",p).then(res=>{
					if(res.data.code){
						location.href = "index.html";
					}else{
						alert(res.data.msg);
					}
				}).catch(function(error){
					console.log(error);
				});
			}
		}
	})
</script>
</body>
</html>
